﻿@page
@model CertsServer.Pages.QuartzAdmin.IndexModel
@{
    ViewData["Title"] = "Triggers";
}

<h2 class="text-2xl">@ViewData["Title"]</h2>

<div>
    <table class="ds-table">
        <thead>
            <tr>
                <th>No.</th>
                <th>Trigger Name</th>
                <th>Job Name</th>
                <th>Previous Fire Time</th>
                <th>Next Fire Time</th>
                <th>Operations</th>
            </tr>
        </thead>
        <tbody>
            @if(Model.Triggers.IsNullOrEmpty()){
                <tr>
                    <td colspan="5">
                        No Data
                    </td>
                </tr>
            }
            else {
                foreach(var (item, index) in Model.Triggers.WithIndex()){
                    <tr>
                        <td>@(index + 1)</td>
                        <td>@(item.Key.Group)+@(item.Key.Name)</td>
                        <td>@(item.JobKey.Group)+@(item.JobKey.Name)</td>
                        <td>
                            @item.PreviousFireTime
                        </td>
                        <td>
                            @item.NextFireTime
                        </td>
                        <td>
                            <form method="post" asp-page-handler="ExecuteNow">
                                <input type="hidden" name="name" value="@item.JobKey.Name" />
                                <input type="hidden" name="group" value="@item.JobKey.Group" />
                                <input type="hidden" name="ticketId" value="@item.Key.Name" />
                                <button type="submit" class="ds-btn ds-btn-primary ds-btn-xs">EXECUTE NOW</button>
                            </form>
                        </td>
                    </tr>
                }
            }
        </tbody>
    </table>
</div>